/*
	libsimple_sdlcore - basic wrappers and helpers for SDL2
	https://notabug.org/namark/libsimple_sdlcore
	https://gitlab.com/namark/libsimple_sdlcore
	https://github.com/namark/libsimple_sdlcore

	Copyright (C) 2017-2019 respective authors/contributors

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SIMPLE_SDLCORE_INITIALIZER_H
#define SIMPLE_SDLCORE_INITIALIZER_H
#include <SDL2/SDL.h>
#include "simple/support/enum_flags_operators.hpp"

namespace simple::sdlcore
{

	enum class system_flag : uint32_t
	{
		nothing = 0,
		video = SDL_INIT_VIDEO,
		audio = SDL_INIT_AUDIO,
		event = SDL_INIT_EVENTS,
		haptic = SDL_INIT_HAPTIC,
		joystick = SDL_INIT_JOYSTICK,
		game_controller = SDL_INIT_GAMECONTROLLER,
		everything = SDL_INIT_EVERYTHING,
	};

	using ::operator|;
	using ::operator&;
	using ::operator^;
	using ::operator&&;

	// NOTE: wanted to use unique_ptr here, but couldn't find an easy way
	class initializer
	{
		public:
		static bool exists(system_flag) noexcept;

		initializer(system_flag = system_flag::everything);
		virtual ~initializer() noexcept;

		initializer(const initializer& other) = delete;
		initializer & operator=(const initializer& other) = delete;
		initializer(initializer&& other) noexcept;
		initializer & operator=(initializer&& other) noexcept;

		private:

		system_flag system;

	};

} // namespace simple::sdlcore

namespace simple::support
{
	template <>
	struct define_enum_flags_operators<simple::sdlcore::system_flag> : public std::true_type {};
} // namespace simple::support

#endif /* end of include guard */
